/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package Interfaz;

import edu.ucue.ECU.exp.BuscarDatosAdministradorException;
import edu.ucue.ECU.exp.BuscarDatosCoordinadorException;
import edu.ucue.ECU.exp.BuscarDatosEmergenciaException;
import edu.ucue.ECU.exp.BuscarDatosEntidadException;
import edu.ucue.ECU.exp.BuscarDatosEstadoException;
import edu.ucue.ECU.exp.BuscarDatosOperadorException;
import edu.ucue.ECU.exp.BuscarDatosPersonaException;
import edu.ucue.ECU.exp.BuscarDatosResponsableException;
import edu.ucue.ECU.exp.GuardarDatosAdministradorException;
import edu.ucue.ECU.exp.GuardarDatosCoordinadorException;
import edu.ucue.ECU.exp.GuardarDatosEmergenciaException;
import edu.ucue.ECU.exp.GuardarDatosEntidadException;
import edu.ucue.ECU.exp.GuardarDatosOperadorException;
import edu.ucue.ECU.exp.GuardarDatosPersonaException;
import edu.ucue.ECU.exp.GuardarDatosResponsableException;
import edu.ucue.ECU.exp.GuardarDatosTipoException;
import edu.ucue.ECU.ngc.Administrador;
import edu.ucue.ECU.ngc.AlarmaFactory;
import edu.ucue.ECU.ngc.Coordinador;
import edu.ucue.ECU.ngc.Emergencia;
import edu.ucue.ECU.ngc.Entidad;
import edu.ucue.ECU.ngc.Estado;
import edu.ucue.ECU.ngc.Operador;
import edu.ucue.ECU.ngc.Persona;
import edu.ucue.ECU.ngc.Responsable;
import edu.ucue.ECU.ngc.Tipo;
import edu.ucue.ECU.ngc.TipoEmergencia;
import java.util.ArrayList;
import java.util.Calendar;
import java.util.logging.Level;
import java.util.logging.Logger;
import javax.swing.JOptionPane;
import javax.swing.table.DefaultTableModel;

/**
 *
 * @author Jorge
 */
public class Menu extends javax.swing.JFrame {
    Persona unaPersona=new Persona();
    Administrador unAdminstrador=new Administrador();
    Coordinador unCoordinador=new Coordinador();
    Operador unaOperador=new Operador();
    Entidad unaEntidad=new Entidad();
    Responsable unResponsable=new Responsable();
    /**
     * Creates new form Menu
     */
    public Menu() {
        initComponents();
        deshabilitar();
    }

    /**
     * This method is called from within the constructor to initialize the form.
     * WARNING: Do NOT modify this code. The content of this method is always
     * regenerated by the Form Editor.
     */
    @SuppressWarnings("unchecked")
    // <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents
    private void initComponents() {

        jSeparator1 = new javax.swing.JSeparator();
        jScrollPane1 = new javax.swing.JScrollPane();
        jEditorPane1 = new javax.swing.JEditorPane();
        jPasswordField1 = new javax.swing.JPasswordField();
        jScrollPane8 = new javax.swing.JScrollPane();
        txaTipos2 = new javax.swing.JTextArea();
        tbpPrincipal = new javax.swing.JTabbedPane();
        jPanel1 = new javax.swing.JPanel();
        jLabel1 = new javax.swing.JLabel();
        jLabel2 = new javax.swing.JLabel();
        txtcedula = new javax.swing.JTextField();
        txtContrasena = new javax.swing.JTextField();
        btnNuevo = new javax.swing.JButton();
        btnConectar = new javax.swing.JButton();
        jPanel2 = new javax.swing.JPanel();
        EstadosEmergencia = new javax.swing.JTabbedPane();
        jPanel5 = new javax.swing.JPanel();
        cmbTipoUsuario = new javax.swing.JComboBox();
        jLabel3 = new javax.swing.JLabel();
        jLabel4 = new javax.swing.JLabel();
        jLabel5 = new javax.swing.JLabel();
        jLabel6 = new javax.swing.JLabel();
        txtCedulausuario = new javax.swing.JTextField();
        txtNombreUsuario = new javax.swing.JTextField();
        txtContrasenausuario = new javax.swing.JTextField();
        btnGrabarusuario = new javax.swing.JButton();
        jScrollPane6 = new javax.swing.JScrollPane();
        tblusuarios = new javax.swing.JTable();
        lblmensaje = new javax.swing.JLabel();
        jPanel12 = new javax.swing.JPanel();
        jScrollPane3 = new javax.swing.JScrollPane();
        tblEntidad = new javax.swing.JTable();
        txtNombre = new javax.swing.JTextField();
        jLabel32 = new javax.swing.JLabel();
        btnGrabarEntidad = new javax.swing.JButton();
        lblResultado = new javax.swing.JLabel();
        jLabel35 = new javax.swing.JLabel();
        txtId1 = new javax.swing.JTextField();
        jSeparator2 = new javax.swing.JSeparator();
        txtCIResponsable = new javax.swing.JTextField();
        jLabel36 = new javax.swing.JLabel();
        jLabel37 = new javax.swing.JLabel();
        txtNombreResponsable = new javax.swing.JTextField();
        txtTelefonoResponsable = new javax.swing.JTextField();
        jLabel38 = new javax.swing.JLabel();
        jLabel39 = new javax.swing.JLabel();
        txtCorreoResponsable = new javax.swing.JTextField();
        jPanel10 = new javax.swing.JPanel();
        jTabbedPane3 = new javax.swing.JTabbedPane();
        jPanel6 = new javax.swing.JPanel();
        jLabel8 = new javax.swing.JLabel();
        jLabel9 = new javax.swing.JLabel();
        jLabel10 = new javax.swing.JLabel();
        txtId = new javax.swing.JTextField();
        txtDescripcion = new javax.swing.JTextField();
        txtUbicacion = new javax.swing.JTextField();
        jLabel11 = new javax.swing.JLabel();
        jLabel12 = new javax.swing.JLabel();
        txtTelefono = new javax.swing.JTextField();
        txtfecha = new javax.swing.JTextField();
        txtCedulaEmergencia = new javax.swing.JTextField();
        jLabel13 = new javax.swing.JLabel();
        jLabel14 = new javax.swing.JLabel();
        txtNombreEmergencia = new javax.swing.JTextField();
        jLabel15 = new javax.swing.JLabel();
        jLabel16 = new javax.swing.JLabel();
        jLabel17 = new javax.swing.JLabel();
        cmbTipoEmergencia = new javax.swing.JComboBox();
        cmbEstadoEmergencia = new javax.swing.JComboBox();
        jLabel22 = new javax.swing.JLabel();
        cmbOperador = new javax.swing.JComboBox();
        cmbGrabarEmergencia = new javax.swing.JButton();
        jScrollPane4 = new javax.swing.JScrollPane();
        txaEntidades = new javax.swing.JTextArea();
        jScrollPane5 = new javax.swing.JScrollPane();
        tblEmergencias = new javax.swing.JTable();
        cmbEntidades = new javax.swing.JComboBox();
        jButton1 = new javax.swing.JButton();
        jButton2 = new javax.swing.JButton();
        jPanel4 = new javax.swing.JPanel();
        jTabbedPane4 = new javax.swing.JTabbedPane();
        jPanel9 = new javax.swing.JPanel();
        jLabel23 = new javax.swing.JLabel();
        jLabel24 = new javax.swing.JLabel();
        jLabel25 = new javax.swing.JLabel();
        txtIdReporte = new javax.swing.JTextField();
        txtdescripcionReporte = new javax.swing.JTextField();
        txtUbicacionReporte = new javax.swing.JTextField();
        jLabel26 = new javax.swing.JLabel();
        jLabel27 = new javax.swing.JLabel();
        txtTelefonoReporte = new javax.swing.JTextField();
        txtfechareporte = new javax.swing.JTextField();
        txtCedulaReporte = new javax.swing.JTextField();
        jLabel28 = new javax.swing.JLabel();
        jLabel29 = new javax.swing.JLabel();
        txtNombreEmergenciaReporte = new javax.swing.JTextField();
        jLabel31 = new javax.swing.JLabel();
        jLabel33 = new javax.swing.JLabel();
        cmbGrabarEmergencia1 = new javax.swing.JButton();
        jPanel3 = new javax.swing.JPanel();
        jScrollPane2 = new javax.swing.JScrollPane();
        txaCaso = new javax.swing.JTextArea();
        cmbBuscar = new javax.swing.JButton();
        txtestadoReporte = new javax.swing.JTextField();
        jLabel34 = new javax.swing.JLabel();
        cmbCoordinador = new javax.swing.JComboBox();
        jLabel7 = new javax.swing.JLabel();
        jScrollPane7 = new javax.swing.JScrollPane();
        txaTiposReporte = new javax.swing.JTextArea();
        jScrollPane9 = new javax.swing.JScrollPane();
        txaEntidadesReporte = new javax.swing.JTextArea();
        jLabel30 = new javax.swing.JLabel();
        txtOperadorReporte = new javax.swing.JTextField();
        lblMensajeBuscarEmergencia = new javax.swing.JLabel();

        jScrollPane1.setViewportView(jEditorPane1);

        jPasswordField1.setText("jPasswordField1");

        txaTipos2.setColumns(20);
        txaTipos2.setRows(5);
        jScrollPane8.setViewportView(txaTipos2);

        setDefaultCloseOperation(javax.swing.WindowConstants.EXIT_ON_CLOSE);

        tbpPrincipal.setTabLayoutPolicy(javax.swing.JTabbedPane.SCROLL_TAB_LAYOUT);
        tbpPrincipal.setTabPlacement(javax.swing.JTabbedPane.LEFT);

        jLabel1.setText("Cedula:");

        jLabel2.setText("Contraseña:");

        btnNuevo.setText("Nuevo");
        btnNuevo.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                btnNuevoActionPerformed(evt);
            }
        });

        btnConectar.setText("Conectar");
        btnConectar.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                btnConectarActionPerformed(evt);
            }
        });

        javax.swing.GroupLayout jPanel1Layout = new javax.swing.GroupLayout(jPanel1);
        jPanel1.setLayout(jPanel1Layout);
        jPanel1Layout.setHorizontalGroup(
            jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(jPanel1Layout.createSequentialGroup()
                .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addGroup(jPanel1Layout.createSequentialGroup()
                        .addGap(137, 137, 137)
                        .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                            .addComponent(jLabel2)
                            .addComponent(jLabel1))
                        .addGap(18, 18, 18)
                        .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING, false)
                            .addComponent(txtContrasena, javax.swing.GroupLayout.DEFAULT_SIZE, 100, Short.MAX_VALUE)
                            .addComponent(txtcedula)))
                    .addGroup(jPanel1Layout.createSequentialGroup()
                        .addGap(120, 120, 120)
                        .addComponent(btnNuevo, javax.swing.GroupLayout.PREFERRED_SIZE, 90, javax.swing.GroupLayout.PREFERRED_SIZE)
                        .addGap(38, 38, 38)
                        .addComponent(btnConectar, javax.swing.GroupLayout.PREFERRED_SIZE, 90, javax.swing.GroupLayout.PREFERRED_SIZE)))
                .addContainerGap(159, Short.MAX_VALUE))
        );
        jPanel1Layout.setVerticalGroup(
            jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(jPanel1Layout.createSequentialGroup()
                .addGap(84, 84, 84)
                .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(jLabel1)
                    .addComponent(txtcedula, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(jLabel2)
                    .addComponent(txtContrasena, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                .addGap(27, 27, 27)
                .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(btnConectar)
                    .addComponent(btnNuevo))
                .addContainerGap(454, Short.MAX_VALUE))
        );

        tbpPrincipal.addTab("Login", jPanel1);

        jPanel5.setBorder(javax.swing.BorderFactory.createTitledBorder("RegistrarUsuario"));
        jPanel5.setPreferredSize(new java.awt.Dimension(344, 343));
        jPanel5.addComponentListener(new java.awt.event.ComponentAdapter() {
            public void componentShown(java.awt.event.ComponentEvent evt) {
                jPanel5ComponentShown(evt);
            }
        });

        cmbTipoUsuario.setModel(new javax.swing.DefaultComboBoxModel(new String[] { "administrador", "operador", "coordinador" }));

        jLabel3.setText("tipo:");

        jLabel4.setText("nombre:");

        jLabel5.setText("cedula:");

        jLabel6.setText("contraseña:");

        btnGrabarusuario.setText("Grabar");
        btnGrabarusuario.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                btnGrabarusuarioActionPerformed(evt);
            }
        });

        tblusuarios.setModel(new javax.swing.table.DefaultTableModel(
            new Object [][] {
                {null, null},
                {null, null},
                {null, null},
                {null, null}
            },
            new String [] {
                "Cedula", "Nombre"
            }
        ));
        jScrollPane6.setViewportView(tblusuarios);

        javax.swing.GroupLayout jPanel5Layout = new javax.swing.GroupLayout(jPanel5);
        jPanel5.setLayout(jPanel5Layout);
        jPanel5Layout.setHorizontalGroup(
            jPanel5Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(jPanel5Layout.createSequentialGroup()
                .addGroup(jPanel5Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addGroup(jPanel5Layout.createSequentialGroup()
                        .addGap(144, 144, 144)
                        .addComponent(btnGrabarusuario))
                    .addGroup(jPanel5Layout.createSequentialGroup()
                        .addContainerGap()
                        .addGroup(jPanel5Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING)
                            .addComponent(jLabel5)
                            .addComponent(jLabel4))
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                        .addGroup(jPanel5Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING, false)
                            .addComponent(txtCedulausuario, javax.swing.GroupLayout.DEFAULT_SIZE, 90, Short.MAX_VALUE)
                            .addComponent(txtNombreUsuario))
                        .addGap(44, 44, 44)
                        .addGroup(jPanel5Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING, false)
                            .addGroup(jPanel5Layout.createSequentialGroup()
                                .addComponent(jLabel3)
                                .addGap(35, 35, 35)
                                .addComponent(cmbTipoUsuario, javax.swing.GroupLayout.PREFERRED_SIZE, 104, javax.swing.GroupLayout.PREFERRED_SIZE))
                            .addGroup(jPanel5Layout.createSequentialGroup()
                                .addComponent(jLabel6)
                                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                                .addComponent(txtContrasenausuario, javax.swing.GroupLayout.PREFERRED_SIZE, 99, javax.swing.GroupLayout.PREFERRED_SIZE))))
                    .addGroup(jPanel5Layout.createSequentialGroup()
                        .addContainerGap()
                        .addComponent(jScrollPane6, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                    .addGroup(jPanel5Layout.createSequentialGroup()
                        .addGap(74, 74, 74)
                        .addComponent(lblmensaje, javax.swing.GroupLayout.PREFERRED_SIZE, 246, javax.swing.GroupLayout.PREFERRED_SIZE)))
                .addContainerGap(18, Short.MAX_VALUE))
        );
        jPanel5Layout.setVerticalGroup(
            jPanel5Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(jPanel5Layout.createSequentialGroup()
                .addGap(13, 13, 13)
                .addComponent(lblmensaje, javax.swing.GroupLayout.PREFERRED_SIZE, 21, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addGroup(jPanel5Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(jLabel5)
                    .addComponent(txtCedulausuario, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addComponent(jLabel6)
                    .addComponent(txtContrasenausuario, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                .addGap(14, 14, 14)
                .addGroup(jPanel5Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(cmbTipoUsuario, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addComponent(jLabel3)
                    .addComponent(jLabel4)
                    .addComponent(txtNombreUsuario, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                .addGap(18, 18, 18)
                .addComponent(btnGrabarusuario)
                .addGap(18, 18, 18)
                .addComponent(jScrollPane6, javax.swing.GroupLayout.PREFERRED_SIZE, 95, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addContainerGap(340, Short.MAX_VALUE))
        );

        EstadosEmergencia.addTab("Usuarios", jPanel5);

        jPanel12.addComponentListener(new java.awt.event.ComponentAdapter() {
            public void componentShown(java.awt.event.ComponentEvent evt) {
                jPanel12ComponentShown(evt);
            }
        });

        tblEntidad.setModel(new javax.swing.table.DefaultTableModel(
            new Object [][] {

            },
            new String [] {
                "Id", "Entidad"
            }
        ) {
            boolean[] canEdit = new boolean [] {
                false, false
            };

            public boolean isCellEditable(int rowIndex, int columnIndex) {
                return canEdit [columnIndex];
            }
        });
        tblEntidad.addMouseListener(new java.awt.event.MouseAdapter() {
            public void mouseClicked(java.awt.event.MouseEvent evt) {
                tblEntidadMouseClicked(evt);
            }
        });
        jScrollPane3.setViewportView(tblEntidad);

        jLabel32.setFont(new java.awt.Font("Tahoma", 1, 11)); // NOI18N
        jLabel32.setText("Entidad:");

        btnGrabarEntidad.setText("Grabar");
        btnGrabarEntidad.setName("btnGrabarEntidad"); // NOI18N
        btnGrabarEntidad.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                btnGrabarEntidadActionPerformed(evt);
            }
        });

        lblResultado.setFont(new java.awt.Font("Tahoma", 1, 11)); // NOI18N
        lblResultado.setForeground(new java.awt.Color(204, 0, 0));

        jLabel35.setFont(new java.awt.Font("Tahoma", 1, 11)); // NOI18N
        jLabel35.setText("Id:");

        txtId1.setEnabled(false);

        jSeparator2.setBorder(javax.swing.BorderFactory.createTitledBorder("Responsable"));
        jSeparator2.setFont(new java.awt.Font("Tahoma", 1, 11)); // NOI18N

        txtCIResponsable.addFocusListener(new java.awt.event.FocusAdapter() {
            public void focusLost(java.awt.event.FocusEvent evt) {
                txtCIResponsableFocusLost(evt);
            }
        });

        jLabel36.setFont(new java.awt.Font("Tahoma", 1, 11)); // NOI18N
        jLabel36.setText("CI:");

        jLabel37.setFont(new java.awt.Font("Tahoma", 1, 11)); // NOI18N
        jLabel37.setText("Nombre:");

        jLabel38.setFont(new java.awt.Font("Tahoma", 1, 11)); // NOI18N
        jLabel38.setText("Teléfono:");

        jLabel39.setFont(new java.awt.Font("Tahoma", 1, 11)); // NOI18N
        jLabel39.setText("Correo:");

        javax.swing.GroupLayout jPanel12Layout = new javax.swing.GroupLayout(jPanel12);
        jPanel12.setLayout(jPanel12Layout);
        jPanel12Layout.setHorizontalGroup(
            jPanel12Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(jPanel12Layout.createSequentialGroup()
                .addContainerGap()
                .addGroup(jPanel12Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addGroup(jPanel12Layout.createSequentialGroup()
                        .addGroup(jPanel12Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING)
                            .addComponent(jLabel32)
                            .addComponent(jLabel35))
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                        .addGroup(jPanel12Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                            .addComponent(txtNombre, javax.swing.GroupLayout.PREFERRED_SIZE, 146, javax.swing.GroupLayout.PREFERRED_SIZE)
                            .addComponent(txtId1, javax.swing.GroupLayout.PREFERRED_SIZE, 76, javax.swing.GroupLayout.PREFERRED_SIZE))
                        .addGap(0, 0, Short.MAX_VALUE))
                    .addGroup(jPanel12Layout.createSequentialGroup()
                        .addComponent(btnGrabarEntidad, javax.swing.GroupLayout.PREFERRED_SIZE, 95, javax.swing.GroupLayout.PREFERRED_SIZE)
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                        .addComponent(lblResultado, javax.swing.GroupLayout.DEFAULT_SIZE, 373, Short.MAX_VALUE))
                    .addGroup(jPanel12Layout.createSequentialGroup()
                        .addGroup(jPanel12Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                            .addGroup(jPanel12Layout.createSequentialGroup()
                                .addGroup(jPanel12Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING)
                                    .addComponent(jLabel37)
                                    .addComponent(jLabel36))
                                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                                .addGroup(jPanel12Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                                    .addComponent(txtNombreResponsable, javax.swing.GroupLayout.PREFERRED_SIZE, 146, javax.swing.GroupLayout.PREFERRED_SIZE)
                                    .addComponent(txtCIResponsable, javax.swing.GroupLayout.PREFERRED_SIZE, 76, javax.swing.GroupLayout.PREFERRED_SIZE)))
                            .addGroup(jPanel12Layout.createSequentialGroup()
                                .addGroup(jPanel12Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING)
                                    .addComponent(jLabel39)
                                    .addComponent(jLabel38))
                                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                                .addGroup(jPanel12Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING, false)
                                    .addComponent(txtCorreoResponsable, javax.swing.GroupLayout.DEFAULT_SIZE, 146, Short.MAX_VALUE)
                                    .addComponent(txtTelefonoResponsable)))
                            .addComponent(jSeparator2, javax.swing.GroupLayout.PREFERRED_SIZE, 225, javax.swing.GroupLayout.PREFERRED_SIZE))
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                        .addComponent(jScrollPane3, javax.swing.GroupLayout.PREFERRED_SIZE, 0, Short.MAX_VALUE)))
                .addContainerGap())
        );
        jPanel12Layout.setVerticalGroup(
            jPanel12Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(jPanel12Layout.createSequentialGroup()
                .addContainerGap()
                .addGroup(jPanel12Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING, false)
                    .addGroup(jPanel12Layout.createSequentialGroup()
                        .addComponent(jScrollPane3, javax.swing.GroupLayout.PREFERRED_SIZE, 253, javax.swing.GroupLayout.PREFERRED_SIZE)
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                        .addComponent(lblResultado, javax.swing.GroupLayout.PREFERRED_SIZE, 18, javax.swing.GroupLayout.PREFERRED_SIZE))
                    .addGroup(jPanel12Layout.createSequentialGroup()
                        .addGroup(jPanel12Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                            .addComponent(jLabel35)
                            .addComponent(txtId1, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                        .addGroup(jPanel12Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                            .addComponent(jLabel32)
                            .addComponent(txtNombre, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                        .addComponent(jSeparator2, javax.swing.GroupLayout.PREFERRED_SIZE, 18, javax.swing.GroupLayout.PREFERRED_SIZE)
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                        .addGroup(jPanel12Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                            .addComponent(txtCIResponsable, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                            .addComponent(jLabel36))
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                        .addGroup(jPanel12Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                            .addComponent(txtNombreResponsable, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                            .addComponent(jLabel37))
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                        .addGroup(jPanel12Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                            .addComponent(jLabel38)
                            .addComponent(txtTelefonoResponsable, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                        .addGroup(jPanel12Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                            .addComponent(jLabel39)
                            .addComponent(txtCorreoResponsable, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                        .addComponent(btnGrabarEntidad)
                        .addGap(86, 86, 86)))
                .addContainerGap(311, Short.MAX_VALUE))
        );

        EstadosEmergencia.addTab("Entidades", jPanel12);

        javax.swing.GroupLayout jPanel2Layout = new javax.swing.GroupLayout(jPanel2);
        jPanel2.setLayout(jPanel2Layout);
        jPanel2Layout.setHorizontalGroup(
            jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addComponent(EstadosEmergencia)
        );
        jPanel2Layout.setVerticalGroup(
            jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addComponent(EstadosEmergencia)
        );

        tbpPrincipal.addTab("Administrador", jPanel2);

        jPanel10.setEnabled(false);
        jPanel10.setFocusable(false);
        jPanel10.setOpaque(false);

        jPanel6.setBorder(javax.swing.BorderFactory.createTitledBorder("Registrar Energencia"));
        jPanel6.setEnabled(false);
        jPanel6.setFocusable(false);
        jPanel6.setOpaque(false);
        jPanel6.addComponentListener(new java.awt.event.ComponentAdapter() {
            public void componentShown(java.awt.event.ComponentEvent evt) {
                jPanel6ComponentShown(evt);
            }
        });

        jLabel8.setText("descripcion:");

        jLabel9.setText("id:");

        jLabel10.setText("ubicacion:");

        txtId.setEnabled(false);

        jLabel11.setText("telefono:");

        jLabel12.setText("fecha:");

        txtfecha.setEnabled(false);

        txtCedulaEmergencia.addFocusListener(new java.awt.event.FocusAdapter() {
            public void focusGained(java.awt.event.FocusEvent evt) {
                txtCedulaEmergenciaFocusGained(evt);
            }
            public void focusLost(java.awt.event.FocusEvent evt) {
                txtCedulaEmergenciaFocusLost(evt);
            }
        });

        jLabel13.setText("cedula:");

        jLabel14.setText("nombre:");

        jLabel15.setText("Tipo:");

        jLabel16.setText("Estado:");

        jLabel17.setText("Entidad:");

        cmbTipoEmergencia.setModel(new javax.swing.DefaultComboBoxModel(new String[] { "Incendio", "Robo", "Accidente" }));
        cmbTipoEmergencia.addItemListener(new java.awt.event.ItemListener() {
            public void itemStateChanged(java.awt.event.ItemEvent evt) {
                cmbTipoEmergenciaItemStateChanged(evt);
            }
        });

        cmbEstadoEmergencia.setModel(new javax.swing.DefaultComboBoxModel(new String[] { "Registrado", "Finalizado" }));

        jLabel22.setText("Operador:");

        cmbOperador.setModel(new javax.swing.DefaultComboBoxModel(new String[] { "Item 1", "Item 2", "Item 3", "Item 4" }));

        cmbGrabarEmergencia.setText("Grabar");
        cmbGrabarEmergencia.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                cmbGrabarEmergenciaActionPerformed(evt);
            }
        });

        txaEntidades.setColumns(20);
        txaEntidades.setRows(5);
        jScrollPane4.setViewportView(txaEntidades);

        tblEmergencias.setModel(new javax.swing.table.DefaultTableModel(
            new Object [][] {
                {null, null, null, null},
                {null, null, null, null},
                {null, null, null, null},
                {null, null, null, null}
            },
            new String [] {
                "Id", "Descripcion", "Ubicacion", "Telefono"
            }
        ));
        jScrollPane5.setViewportView(tblEmergencias);

        cmbEntidades.setModel(new javax.swing.DefaultComboBoxModel(new String[] { "Item 1", "Item 2", "Item 3", "Item 4" }));

        jButton1.setText("Quitar");
        jButton1.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jButton1ActionPerformed(evt);
            }
        });

        jButton2.setText("Agregar");
        jButton2.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jButton2ActionPerformed(evt);
            }
        });

        javax.swing.GroupLayout jPanel6Layout = new javax.swing.GroupLayout(jPanel6);
        jPanel6.setLayout(jPanel6Layout);
        jPanel6Layout.setHorizontalGroup(
            jPanel6Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(jPanel6Layout.createSequentialGroup()
                .addGroup(jPanel6Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addGroup(jPanel6Layout.createSequentialGroup()
                        .addGap(187, 187, 187)
                        .addComponent(cmbGrabarEmergencia))
                    .addGroup(jPanel6Layout.createSequentialGroup()
                        .addContainerGap()
                        .addComponent(jScrollPane5, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)))
                .addContainerGap(18, Short.MAX_VALUE))
            .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, jPanel6Layout.createSequentialGroup()
                .addContainerGap()
                .addGroup(jPanel6Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING)
                    .addGroup(javax.swing.GroupLayout.Alignment.LEADING, jPanel6Layout.createSequentialGroup()
                        .addGroup(jPanel6Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING)
                            .addComponent(jLabel13)
                            .addComponent(jLabel11)
                            .addComponent(jLabel9)
                            .addComponent(jLabel8)
                            .addComponent(jLabel10)
                            .addComponent(jLabel15))
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                        .addGroup(jPanel6Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING)
                            .addComponent(cmbTipoEmergencia, javax.swing.GroupLayout.Alignment.LEADING, 0, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                            .addComponent(txtCedulaEmergencia, javax.swing.GroupLayout.Alignment.LEADING)
                            .addComponent(txtTelefono, javax.swing.GroupLayout.Alignment.LEADING)
                            .addComponent(txtDescripcion, javax.swing.GroupLayout.Alignment.LEADING)
                            .addComponent(txtUbicacion, javax.swing.GroupLayout.Alignment.LEADING)
                            .addComponent(txtId))
                        .addGap(22, 22, 22)
                        .addGroup(jPanel6Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING)
                            .addComponent(jLabel16)
                            .addComponent(jLabel14)
                            .addComponent(jLabel22)
                            .addComponent(jLabel12)
                            .addComponent(jLabel17))
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                        .addGroup(jPanel6Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                            .addComponent(txtfecha)
                            .addComponent(txtNombreEmergencia)
                            .addGroup(jPanel6Layout.createSequentialGroup()
                                .addGap(21, 21, 21)
                                .addGroup(jPanel6Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                                    .addComponent(cmbEstadoEmergencia, javax.swing.GroupLayout.Alignment.TRAILING, 0, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                                    .addComponent(cmbOperador, javax.swing.GroupLayout.Alignment.TRAILING, 0, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)))
                            .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, jPanel6Layout.createSequentialGroup()
                                .addGap(25, 25, 25)
                                .addComponent(cmbEntidades, 0, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))))
                    .addGroup(jPanel6Layout.createSequentialGroup()
                        .addGap(0, 0, Short.MAX_VALUE)
                        .addGroup(jPanel6Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING, false)
                            .addComponent(jScrollPane4, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                            .addGroup(jPanel6Layout.createSequentialGroup()
                                .addComponent(jButton2)
                                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                                .addComponent(jButton1)))))
                .addGap(49, 49, 49))
        );
        jPanel6Layout.setVerticalGroup(
            jPanel6Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(jPanel6Layout.createSequentialGroup()
                .addGroup(jPanel6Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(jLabel13)
                    .addComponent(txtCedulaEmergencia, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addComponent(jLabel14)
                    .addComponent(txtNombreEmergencia, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                .addGap(5, 5, 5)
                .addGroup(jPanel6Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(jLabel9)
                    .addComponent(txtId, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addComponent(jLabel12)
                    .addComponent(txtfecha, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addGroup(jPanel6Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addGroup(jPanel6Layout.createSequentialGroup()
                        .addGroup(jPanel6Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                            .addComponent(jLabel8)
                            .addComponent(txtDescripcion, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                        .addGroup(jPanel6Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                            .addComponent(jLabel10)
                            .addComponent(txtUbicacion, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)))
                    .addGroup(jPanel6Layout.createSequentialGroup()
                        .addGroup(jPanel6Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                            .addComponent(jLabel16)
                            .addComponent(cmbEstadoEmergencia, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                        .addGap(11, 11, 11)
                        .addGroup(jPanel6Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                            .addComponent(jLabel22)
                            .addComponent(cmbOperador, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))))
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addGroup(jPanel6Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(jLabel11)
                    .addComponent(txtTelefono, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addGroup(jPanel6Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(cmbTipoEmergencia, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addComponent(jLabel15)
                    .addComponent(jLabel17)
                    .addComponent(cmbEntidades, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                .addGap(5, 5, 5)
                .addGroup(jPanel6Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(jButton1)
                    .addComponent(jButton2))
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addComponent(jScrollPane4, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addGap(9, 9, 9)
                .addComponent(cmbGrabarEmergencia)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addComponent(jScrollPane5, javax.swing.GroupLayout.PREFERRED_SIZE, 149, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addContainerGap(117, Short.MAX_VALUE))
        );

        jTabbedPane3.addTab("Emergencia", jPanel6);

        javax.swing.GroupLayout jPanel10Layout = new javax.swing.GroupLayout(jPanel10);
        jPanel10.setLayout(jPanel10Layout);
        jPanel10Layout.setHorizontalGroup(
            jPanel10Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addComponent(jTabbedPane3)
        );
        jPanel10Layout.setVerticalGroup(
            jPanel10Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addComponent(jTabbedPane3)
        );

        tbpPrincipal.addTab("Operador", jPanel10);

        jPanel9.setBorder(javax.swing.BorderFactory.createTitledBorder("Registrar Energencia"));
        jPanel9.addComponentListener(new java.awt.event.ComponentAdapter() {
            public void componentShown(java.awt.event.ComponentEvent evt) {
                jPanel9ComponentShown(evt);
            }
        });

        jLabel23.setText("descripcion:");

        jLabel24.setText("id:");

        jLabel25.setText("ubicacion:");

        jLabel26.setText("telefono:");

        jLabel27.setText("fecha:");

        jLabel28.setText("cedula:");

        jLabel29.setText("nombre:");

        jLabel31.setText("Estado:");

        jLabel33.setText("Operador:");

        cmbGrabarEmergencia1.setText("Grabar");
        cmbGrabarEmergencia1.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                cmbGrabarEmergencia1ActionPerformed(evt);
            }
        });

        jPanel3.setBorder(javax.swing.BorderFactory.createTitledBorder("Documentar Caso (Descripcion)"));

        txaCaso.setColumns(20);
        txaCaso.setRows(5);
        jScrollPane2.setViewportView(txaCaso);

        javax.swing.GroupLayout jPanel3Layout = new javax.swing.GroupLayout(jPanel3);
        jPanel3.setLayout(jPanel3Layout);
        jPanel3Layout.setHorizontalGroup(
            jPanel3Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(jPanel3Layout.createSequentialGroup()
                .addContainerGap()
                .addComponent(jScrollPane2)
                .addContainerGap())
        );
        jPanel3Layout.setVerticalGroup(
            jPanel3Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(jPanel3Layout.createSequentialGroup()
                .addComponent(jScrollPane2, javax.swing.GroupLayout.DEFAULT_SIZE, 119, Short.MAX_VALUE)
                .addContainerGap())
        );

        cmbBuscar.setText("Buscar");
        cmbBuscar.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                cmbBuscarActionPerformed(evt);
            }
        });

        txtestadoReporte.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                txtestadoReporteActionPerformed(evt);
            }
        });

        jLabel34.setText("Coordinador:");

        cmbCoordinador.setModel(new javax.swing.DefaultComboBoxModel(new String[] { "Item 1", "Item 2", "Item 3", "Item 4" }));

        jLabel7.setText("Tipos:");

        txaTiposReporte.setColumns(20);
        txaTiposReporte.setRows(5);
        jScrollPane7.setViewportView(txaTiposReporte);

        txaEntidadesReporte.setColumns(20);
        txaEntidadesReporte.setRows(5);
        jScrollPane9.setViewportView(txaEntidadesReporte);

        jLabel30.setText("Entidades:");

        javax.swing.GroupLayout jPanel9Layout = new javax.swing.GroupLayout(jPanel9);
        jPanel9.setLayout(jPanel9Layout);
        jPanel9Layout.setHorizontalGroup(
            jPanel9Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(jPanel9Layout.createSequentialGroup()
                .addContainerGap()
                .addGroup(jPanel9Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, jPanel9Layout.createSequentialGroup()
                        .addGroup(jPanel9Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING)
                            .addGroup(jPanel9Layout.createSequentialGroup()
                                .addGap(0, 0, Short.MAX_VALUE)
                                .addGroup(jPanel9Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING, false)
                                    .addGroup(jPanel9Layout.createSequentialGroup()
                                        .addGap(10, 10, 10)
                                        .addGroup(jPanel9Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING)
                                            .addGroup(jPanel9Layout.createSequentialGroup()
                                                .addComponent(jLabel27)
                                                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                                                .addComponent(txtfechareporte, javax.swing.GroupLayout.PREFERRED_SIZE, 150, javax.swing.GroupLayout.PREFERRED_SIZE))
                                            .addGroup(jPanel9Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                                                .addGroup(jPanel9Layout.createSequentialGroup()
                                                    .addGap(3, 3, 3)
                                                    .addComponent(jLabel31)
                                                    .addGap(4, 4, 4)
                                                    .addComponent(txtestadoReporte, javax.swing.GroupLayout.PREFERRED_SIZE, 150, javax.swing.GroupLayout.PREFERRED_SIZE))
                                                .addGroup(jPanel9Layout.createSequentialGroup()
                                                    .addComponent(jLabel29)
                                                    .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                                                    .addComponent(txtNombreEmergenciaReporte, javax.swing.GroupLayout.PREFERRED_SIZE, 150, javax.swing.GroupLayout.PREFERRED_SIZE))
                                                .addComponent(cmbBuscar, javax.swing.GroupLayout.PREFERRED_SIZE, 97, javax.swing.GroupLayout.PREFERRED_SIZE))))
                                    .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, jPanel9Layout.createSequentialGroup()
                                        .addGroup(jPanel9Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING)
                                            .addComponent(jLabel30)
                                            .addComponent(jLabel33))
                                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                                        .addComponent(txtOperadorReporte))))
                            .addGroup(jPanel9Layout.createSequentialGroup()
                                .addGroup(jPanel9Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING)
                                    .addGroup(jPanel9Layout.createSequentialGroup()
                                        .addGap(0, 0, Short.MAX_VALUE)
                                        .addComponent(jScrollPane7, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                                    .addGroup(jPanel9Layout.createSequentialGroup()
                                        .addGroup(jPanel9Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING)
                                            .addComponent(jLabel28)
                                            .addComponent(jLabel26)
                                            .addComponent(jLabel23)
                                            .addComponent(jLabel25)
                                            .addComponent(jLabel24)
                                            .addComponent(jLabel7))
                                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                                        .addGroup(jPanel9Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING)
                                            .addComponent(txtTelefonoReporte, javax.swing.GroupLayout.Alignment.LEADING)
                                            .addComponent(txtUbicacionReporte, javax.swing.GroupLayout.Alignment.LEADING)
                                            .addComponent(txtIdReporte, javax.swing.GroupLayout.Alignment.LEADING)
                                            .addComponent(txtCedulaReporte, javax.swing.GroupLayout.Alignment.LEADING)
                                            .addComponent(txtdescripcionReporte, javax.swing.GroupLayout.Alignment.LEADING))))
                                .addGap(56, 56, 56)
                                .addComponent(jScrollPane9, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)))
                        .addGap(40, 40, 40))
                    .addGroup(jPanel9Layout.createSequentialGroup()
                        .addGroup(jPanel9Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                            .addComponent(jPanel3, javax.swing.GroupLayout.Alignment.TRAILING, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                            .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, jPanel9Layout.createSequentialGroup()
                                .addComponent(jLabel34)
                                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                                .addComponent(cmbCoordinador, javax.swing.GroupLayout.PREFERRED_SIZE, 143, javax.swing.GroupLayout.PREFERRED_SIZE)
                                .addGap(223, 223, 223))
                            .addGroup(jPanel9Layout.createSequentialGroup()
                                .addGap(184, 184, 184)
                                .addComponent(cmbGrabarEmergencia1)
                                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, 188, javax.swing.GroupLayout.PREFERRED_SIZE)))
                        .addContainerGap())))
            .addGroup(jPanel9Layout.createSequentialGroup()
                .addGap(84, 84, 84)
                .addComponent(lblMensajeBuscarEmergencia, javax.swing.GroupLayout.PREFERRED_SIZE, 306, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addGap(0, 0, Short.MAX_VALUE))
        );
        jPanel9Layout.setVerticalGroup(
            jPanel9Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, jPanel9Layout.createSequentialGroup()
                .addContainerGap()
                .addComponent(lblMensajeBuscarEmergencia, javax.swing.GroupLayout.DEFAULT_SIZE, 23, Short.MAX_VALUE)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                .addGroup(jPanel9Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addGroup(jPanel9Layout.createSequentialGroup()
                        .addGroup(jPanel9Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                            .addComponent(txtIdReporte, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                            .addComponent(jLabel24))
                        .addGap(9, 9, 9))
                    .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, jPanel9Layout.createSequentialGroup()
                        .addComponent(cmbBuscar)
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)))
                .addGroup(jPanel9Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(txtCedulaReporte, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addComponent(jLabel28)
                    .addComponent(jLabel29)
                    .addComponent(txtNombreEmergenciaReporte, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addGroup(jPanel9Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(jLabel23)
                    .addComponent(txtdescripcionReporte, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addComponent(jLabel27)
                    .addComponent(txtfechareporte, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addGroup(jPanel9Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(jLabel25)
                    .addComponent(txtUbicacionReporte, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addComponent(txtestadoReporte, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addComponent(jLabel31))
                .addGroup(jPanel9Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addGroup(jPanel9Layout.createSequentialGroup()
                        .addGap(16, 16, 16)
                        .addComponent(jLabel26))
                    .addGroup(jPanel9Layout.createSequentialGroup()
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                        .addGroup(jPanel9Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                            .addComponent(txtTelefonoReporte, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                            .addComponent(jLabel33)
                            .addComponent(txtOperadorReporte, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))))
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addGroup(jPanel9Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING)
                    .addComponent(jLabel7)
                    .addComponent(jLabel30))
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addGroup(jPanel9Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING)
                    .addComponent(jScrollPane7, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addComponent(jScrollPane9, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                .addGap(18, 18, 18)
                .addGroup(jPanel9Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(cmbCoordinador, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addComponent(jLabel34))
                .addGap(18, 18, 18)
                .addComponent(jPanel3, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addGap(18, 18, 18)
                .addComponent(cmbGrabarEmergencia1)
                .addGap(35, 35, 35))
        );

        jTabbedPane4.addTab("Reporte", jPanel9);

        javax.swing.GroupLayout jPanel4Layout = new javax.swing.GroupLayout(jPanel4);
        jPanel4.setLayout(jPanel4Layout);
        jPanel4Layout.setHorizontalGroup(
            jPanel4Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, jPanel4Layout.createSequentialGroup()
                .addGap(0, 31, Short.MAX_VALUE)
                .addComponent(jTabbedPane4, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
        );
        jPanel4Layout.setVerticalGroup(
            jPanel4Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addComponent(jTabbedPane4)
        );

        tbpPrincipal.addTab("Coordinador", jPanel4);

        javax.swing.GroupLayout layout = new javax.swing.GroupLayout(getContentPane());
        getContentPane().setLayout(layout);
        layout.setHorizontalGroup(
            layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addComponent(tbpPrincipal, javax.swing.GroupLayout.DEFAULT_SIZE, 584, Short.MAX_VALUE)
        );
        layout.setVerticalGroup(
            layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addComponent(tbpPrincipal)
        );

        pack();
    }// </editor-fold>//GEN-END:initComponents
    
    private void txtestadoReporteActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_txtestadoReporteActionPerformed
        // TODO add your handling code here:
    }//GEN-LAST:event_txtestadoReporteActionPerformed

    private void btnGrabarusuarioActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_btnGrabarusuarioActionPerformed
        // TODO add your handling code here:
        if(txtCedulausuario.getText().equals("")||txtNombreUsuario.getText().equals("")||txtContrasenausuario.getText().equals(""))
            JOptionPane.showMessageDialog(this, "Llene todos los campos");
        else
        {
             if(cmbTipoUsuario.getSelectedItem().equals("administrador"))
            {
                unAdminstrador.setCedula(txtCedulausuario.getText());
                unAdminstrador.setNombre(txtNombreUsuario.getText());
                unAdminstrador.setContrasena(txtContrasenausuario.getText());
                try {
                    unAdminstrador.grabarDatosAdministrador();
                    lblmensaje.setText("Administrador: datos guardados");
                } catch (GuardarDatosAdministradorException ex) {
                    lblmensaje.setText(ex.getMessage());
                }

            }
            else if(cmbTipoUsuario.getSelectedItem().equals("coordinador"))
            {
                unCoordinador.setCedula(txtCedulausuario.getText());
                unCoordinador.setNombre(txtNombreUsuario.getText());
                unCoordinador.setContrasena(txtContrasenausuario.getText());

                try {
                    unCoordinador.grabarDatosCoordinador();
                    lblmensaje.setText("Coordinador: datos guardados");
                } catch (GuardarDatosCoordinadorException ex) {
                    lblmensaje.setText(ex.getMessage());
                }
            }
            else if(cmbTipoUsuario.getSelectedItem().equals("operador"))
            {
                unaOperador.setCedula(txtCedulausuario.getText());
                unaOperador.setNombre(txtNombreUsuario.getText());
                unaOperador.setContrasena(txtContrasenausuario.getText());

                try {
                    unaOperador.grabarDatosOperador();
                    lblmensaje.setText("Operador: datos guardados");
                } catch (GuardarDatosOperadorException ex) {
                    lblmensaje.setText(ex.getMessage());
                }
            }
                Actualizarusuarios();           
        }

        
    }//GEN-LAST:event_btnGrabarusuarioActionPerformed

    private void txtCedulaEmergenciaFocusGained(java.awt.event.FocusEvent evt) {//GEN-FIRST:event_txtCedulaEmergenciaFocusGained
        
    }//GEN-LAST:event_txtCedulaEmergenciaFocusGained

    private void txtCedulaEmergenciaFocusLost(java.awt.event.FocusEvent evt) {//GEN-FIRST:event_txtCedulaEmergenciaFocusLost
        unaPersona.setCedula(txtCedulaEmergencia.getText());
        try {
            if (unaPersona.buscar()!=null){
                txtNombreEmergencia.setText(unaPersona.getNombre());
            }
        } catch (BuscarDatosPersonaException ex) {
            JOptionPane.showMessageDialog(this, ex.getMessage());
        }
    }//GEN-LAST:event_txtCedulaEmergenciaFocusLost

    private void jPanel6ComponentShown(java.awt.event.ComponentEvent evt) {//GEN-FIRST:event_jPanel6ComponentShown
        try {
            txtfecha.setText(Calendar.getInstance().getTime().getDay()+"/"+(Calendar.getInstance().getTime().getMonth()+1)+"/"+(Calendar.getInstance().getTime().getYear()+1900));
            
                ArrayList operadores=new Operador().listar();
                cmbOperador.removeAllItems();
                for (int i=0;i<operadores.size();i++){
                    Operador aux=(Operador) operadores.get(i);
                    cmbOperador.addItem(aux.getNombre());
                }
        } catch (BuscarDatosOperadorException ex) {
            JOptionPane.showMessageDialog(this, ex.getMessage());
        }
        try {
            
                ArrayList tipos=new Tipo().listar();
                cmbTipoEmergencia.removeAllItems();
                for (int i=0;i<tipos.size();i++){
                    Tipo aux=(Tipo) tipos.get(i);
                    cmbTipoEmergencia.addItem(aux.getNombre());
                }
        } catch (BuscarDatosEmergenciaException ex) {
            JOptionPane.showMessageDialog(this, ex.getMessage());
        }
        try {
            
                ArrayList entidades=new Entidad().listar();
                cmbEntidades.removeAllItems();
                for (int i=0;i<entidades.size();i++){
                    Entidad aux=(Entidad) entidades.get(i);
                    cmbEntidades.addItem(aux.getNombre());
                }
        } catch (BuscarDatosEntidadException ex) {
            JOptionPane.showMessageDialog(this, ex.getMessage());
        }
        switch (cmbTipoEmergencia.getSelectedItem().toString()){
            case("Incendio"):
                txaEntidades.setText("Bomberos\nCruz Roja\nTransito");
            break;
            case("Robo"):
                txaEntidades.setText("Policia");
            break;
            case("Accidente"):
                txaEntidades.setText("Policia\nCruz Roja\nTransito");
            break;
        }
        Actualizar();
    }//GEN-LAST:event_jPanel6ComponentShown

    private void cmbGrabarEmergenciaActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_cmbGrabarEmergenciaActionPerformed
        Emergencia emergencia=new Emergencia();
        Persona persona=new Persona();
        Operador operador=new Operador();
        Estado estado=new Estado();
        Tipo tipo=new Tipo();
        try {
            operador.setNombre(cmbOperador.getSelectedItem().toString());
            operador.buscarNombre();
            estado.setNombre("Registrado");
            estado.buscar();
            tipo.setNombre(cmbTipoEmergencia.getSelectedItem().toString());
            tipo.buscar();
        } catch (BuscarDatosOperadorException ex) {
            JOptionPane.showMessageDialog(this, ex.getMessage());
        } catch (BuscarDatosEstadoException ex) {
            JOptionPane.showMessageDialog(this, ex.getMessage());
        } catch (BuscarDatosEmergenciaException ex) {
            JOptionPane.showMessageDialog(this, ex.getMessage());
        }
            persona.setCedula(txtCedulaEmergencia.getText());
            persona.setNombre(txtNombreEmergencia.getText());
            emergencia.setPersona(persona);
            emergencia.setEstado(estado);
            emergencia.setOperador(operador);
            emergencia.setTipo(tipo);
        try {
            if (persona.buscar()==null){
                persona.grabar();
            }
        } catch (BuscarDatosPersonaException ex) {
            JOptionPane.showMessageDialog(this, ex.getMessage());
        } catch (GuardarDatosPersonaException ex) {
            JOptionPane.showMessageDialog(this, ex.getMessage());
        }   
            emergencia.setDescripcion(this.txtDescripcion.getText());
            emergencia.setTelefono(this.txtTelefono.getText());
            emergencia.setUbicacion(txtUbicacion.getText());
            emergencia.setFecha(txtfecha.getText());
        try {
            emergencia.grabar();
        } catch (GuardarDatosEmergenciaException ex) {
            JOptionPane.showMessageDialog(this, ex.getMessage());
        } catch (BuscarDatosEmergenciaException ex) {
            JOptionPane.showMessageDialog(this, ex.getMessage());
        }
        
        
        
        AlarmaFactory generador= new AlarmaFactory();
        try {
            TipoEmergencia unaEmergencia =generador.crearAlarma(cmbTipoEmergencia.getSelectedItem().toString());
            JOptionPane.showMessageDialog(this,unaEmergencia.notificar());
        } catch (BuscarDatosEmergenciaException ex) {
            JOptionPane.showMessageDialog(this, ex.getMessage());
        }
        Actualizar();
    }//GEN-LAST:event_cmbGrabarEmergenciaActionPerformed

    private void cmbTipoEmergenciaItemStateChanged(java.awt.event.ItemEvent evt) {//GEN-FIRST:event_cmbTipoEmergenciaItemStateChanged
        if (cmbTipoEmergencia.getItemCount()>0){
            try {
                Tipo tipo=new Tipo();
                tipo.setNombre(cmbTipoEmergencia.getSelectedItem().toString());
                ArrayList entidades= tipo.listarEntidades();
                String res="";
                for (int i=0;i<entidades.size();i++)res=res+entidades.get(i)+"\n";
                txaEntidades.setText(res);
            } catch (BuscarDatosEmergenciaException ex) {
                JOptionPane.showMessageDialog(this, ex.getMessage());
            }
        }
    }//GEN-LAST:event_cmbTipoEmergenciaItemStateChanged

    private void cmbBuscarActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_cmbBuscarActionPerformed
        // TODO add your handling code here:
        Emergencia emergencia=new Emergencia();
        ArrayList resultado=new ArrayList();
        try {
            resultado.addAll(emergencia.RecuperarReporte(Integer.parseInt(txtIdReporte.getText()+"")));
            txtCedulaReporte.setText(((ArrayList)resultado.get(0)).get(0).toString());
            txtNombreEmergencia.setText(((ArrayList)resultado.get(0)).get(1).toString());
            txtdescripcionReporte.setText(((ArrayList)resultado.get(0)).get(2).toString());
            txtUbicacionReporte.setText(((ArrayList)resultado.get(0)).get(3).toString());
            txtTelefonoReporte.setText(((ArrayList)resultado.get(0)).get(4).toString());
            txtfechareporte.setText(((ArrayList)resultado.get(0)).get(5).toString());
            txtestadoReporte.setText(((ArrayList)resultado.get(0)).get(6).toString());
            txtOperadorReporte.setText(((ArrayList)resultado.get(0)).get(7).toString());
            txaTiposReporte.append(((ArrayList)resultado.get(0)).get(8).toString());
            for (int i=0;i<resultado.size();i++)
            {
                txaEntidadesReporte.append(((ArrayList)resultado.get(i)).get(9).toString()+"\n");
            }           
        } catch (BuscarDatosEmergenciaException ex) {
            lblMensajeBuscarEmergencia.setText(ex.getMessage());
        }
        catch (IndexOutOfBoundsException ex) {
            lblMensajeBuscarEmergencia.setText("ERROR: no existe la emergencia");
        }        
        
    }//GEN-LAST:event_cmbBuscarActionPerformed

    private void jPanel9ComponentShown(java.awt.event.ComponentEvent evt) {//GEN-FIRST:event_jPanel9ComponentShown
        // TODO add your handling code here:
        try {
                ArrayList operadores=new Coordinador().listar();
                cmbCoordinador.removeAllItems();
                for (int i=0;i<operadores.size();i++){
                    Coordinador aux=(Coordinador) operadores.get(i);
                    cmbCoordinador.addItem(aux.getNombre());
                }
        } catch (BuscarDatosCoordinadorException ex) {
            JOptionPane.showMessageDialog(this, ex.getMessage());
        }        
    }//GEN-LAST:event_jPanel9ComponentShown

    private void cmbGrabarEmergencia1ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_cmbGrabarEmergencia1ActionPerformed
        // TODO add your handling code here:
        Coordinador operador=new Coordinador();
        Emergencia e=new Emergencia();
        try {
            operador.setNombre(cmbCoordinador.getSelectedItem().toString());
            operador.buscarNombre();
            e.grabarcaso(txaCaso.getText(), Integer.parseInt(txtIdReporte.getText()), operador.getCedula());
        } catch (BuscarDatosCoordinadorException ex) {
            JOptionPane.showMessageDialog(this, ex.getMessage());
        } catch (GuardarDatosEmergenciaException ex) {
            Logger.getLogger(Menu.class.getName()).log(Level.SEVERE, null, ex);
        } catch (BuscarDatosEmergenciaException ex) {
            Logger.getLogger(Menu.class.getName()).log(Level.SEVERE, null, ex);
        }
    }//GEN-LAST:event_cmbGrabarEmergencia1ActionPerformed

    private void btnConectarActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_btnConectarActionPerformed
        // TODO add your handling code here:
        unAdminstrador.setCedula(txtcedula.getText());
        unCoordinador.setCedula(txtcedula.getText());
        unaOperador.setCedula(txtcedula.getText());
        tbpPrincipal.setEnabledAt(1, true);
        tbpPrincipal.setEnabledAt(2, true);
        tbpPrincipal.setEnabledAt(3, true);
        unCoordinador.setCedula(txtcedula.getText());
        unaOperador.setCedula(txtcedula.getText());
        try {
           if(((Administrador)unAdminstrador.buscar(unAdminstrador))!=null && ((Administrador)unAdminstrador.buscar(unAdminstrador)).getContrasena().equals(txtContrasena.getText()))
           {
               tbpPrincipal.setEnabledAt(3, false);
               tbpPrincipal.setEnabledAt(2, false);
               btnConectar.setEnabled(false);
           }
           else if(((Coordinador)unCoordinador.buscar(unCoordinador))!=null && ((Coordinador)unCoordinador.buscar(unCoordinador)).getContrasena().equals(txtContrasena.getText()))
           {
               tbpPrincipal.setEnabledAt(1, false);
               tbpPrincipal.setEnabledAt(2, false);
               btnConectar.setEnabled(false);
           }
           else if(((Operador)unaOperador.buscar(unaOperador))!=null && ((Operador)unaOperador.buscar(unaOperador)).getContrasena().equals(txtContrasena.getText()))
           {
               tbpPrincipal.setEnabledAt(1, false);
               tbpPrincipal.setEnabledAt(3, false);
               btnConectar.setEnabled(false);
           }
           else
           {
               deshabilitar();
               JOptionPane.showMessageDialog(this, "Compruebe el nombre de usuario o contraeña");
           }
        } catch (BuscarDatosOperadorException ex) {
            JOptionPane.showMessageDialog(this, "El operador No existe");
        } catch (BuscarDatosAdministradorException ex) {
            JOptionPane.showMessageDialog(this, "El adminisitrador No existe");
        } catch (BuscarDatosCoordinadorException ex) {
            JOptionPane.showMessageDialog(this, "El coordinador No existe");
        }
    }//GEN-LAST:event_btnConectarActionPerformed

    private void btnNuevoActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_btnNuevoActionPerformed
        // TODO add your handling code here:
        txtcedula.setText(null);
        txtContrasena.setText(null);
        btnConectar.setEnabled(true);
        tbpPrincipal.setEnabledAt(1, false);
        tbpPrincipal.setEnabledAt(2, false);
        tbpPrincipal.setEnabledAt(3, false);
    }//GEN-LAST:event_btnNuevoActionPerformed

    private void jPanel5ComponentShown(java.awt.event.ComponentEvent evt) {//GEN-FIRST:event_jPanel5ComponentShown
            Actualizarusuarios();
    }//GEN-LAST:event_jPanel5ComponentShown

    private void tblEntidadMouseClicked(java.awt.event.MouseEvent evt) {//GEN-FIRST:event_tblEntidadMouseClicked
        unaEntidad.setIdEntidad(Integer.parseInt(String.valueOf(this.tblEntidad.getValueAt(this.tblEntidad.getSelectedRow(), 0))));
        unaEntidad.setNombre(String.valueOf(this.tblEntidad.getValueAt(this.tblEntidad.getSelectedRow(), 1)));
        this.txtId.setText(String.valueOf(unaEntidad.getIdEntidad()));
        this.txtNombre.setText(unaEntidad.getNombre());
        try {
            Responsable aux=unaEntidad.getResponsable();
            if (aux!=null){
                unResponsable=aux;
                txtCIResponsable.setText(unResponsable.getCedula());
                txtNombreResponsable.setText(unResponsable.getNombre());
                txtTelefonoResponsable.setText(unResponsable.getTelefonos());
                txtCorreoResponsable.setText(unResponsable.getCorreos());
            }
        } catch (BuscarDatosResponsableException ex) {
            JOptionPane.showMessageDialog(this, ex.getMessage());
        }
    }//GEN-LAST:event_tblEntidadMouseClicked

    private void btnGrabarEntidadActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_btnGrabarEntidadActionPerformed
        if (this.txtNombre.getText().equals("")) {
            JOptionPane.showMessageDialog(this, "Error. \nIngrese el campo Entidad");
        } else {
            unaEntidad.setNombre(this.txtNombre.getText());
            try {
                unaEntidad.grabar();
                unaEntidad.buscar();
            } catch (GuardarDatosEntidadException ex) {
                JOptionPane.showMessageDialog(this, ex.getMessage());
            } catch (BuscarDatosEntidadException ex) {
                JOptionPane.showMessageDialog(this, ex.getMessage());
            }
            unResponsable.setCedula(txtCIResponsable.getText());
            unResponsable.setNombre(txtNombreResponsable.getText());
            unResponsable.setTelefonos(txtTelefonoResponsable.getText());
            unResponsable.setCorreos(txtCorreoResponsable.getText());
            unResponsable.setEntidad(unaEntidad);
            try {
                if (unResponsable.buscarResponsable()==null){
                    unResponsable.grabarResponsable();
                }
            } catch (BuscarDatosResponsableException ex) {
                JOptionPane.showMessageDialog(this, ex.getMessage());
            } catch (GuardarDatosResponsableException ex) {
                JOptionPane.showMessageDialog(this, ex.getMessage());
            }
            this.lblResultado.setText("Datos Grabados");

            ActualizarEntidades();
        }
    }//GEN-LAST:event_btnGrabarEntidadActionPerformed

    private void txtCIResponsableFocusLost(java.awt.event.FocusEvent evt) {//GEN-FIRST:event_txtCIResponsableFocusLost
        unResponsable.setCedula(txtCIResponsable.getText());
        try {
            if (unResponsable.buscarResponsable()!=null){
                txtNombreResponsable.setText(unResponsable.getNombre());
                txtTelefonoResponsable.setText(unResponsable.getTelefonos());
                txtCorreoResponsable.setText(unResponsable.getCorreos());
            }
        } catch (BuscarDatosResponsableException ex) {
            JOptionPane.showMessageDialog(this, ex.getMessage());
        }
    }//GEN-LAST:event_txtCIResponsableFocusLost

    private void jPanel12ComponentShown(java.awt.event.ComponentEvent evt) {//GEN-FIRST:event_jPanel12ComponentShown
        // TODO add your handling code here:
        ActualizarEntidades();
    }//GEN-LAST:event_jPanel12ComponentShown

    private void jButton2ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jButton2ActionPerformed
        Tipo tipo=new Tipo();
         Entidad entidad=new Entidad();
        try {
            
            tipo.setNombre(cmbTipoEmergencia.getSelectedItem().toString());
            tipo.buscar();
            
           
            entidad.setNombre(cmbEntidades.getSelectedItem().toString());
            entidad.buscar();
            tipo.agregarEntidad(entidad);
            
        } catch (BuscarDatosEntidadException ex) {
            JOptionPane.showMessageDialog(this, ex.getMessage());
        } catch (BuscarDatosEmergenciaException ex) {
            JOptionPane.showMessageDialog(this, ex.getMessage());
        } catch (GuardarDatosEmergenciaException ex) {
            Logger.getLogger(Menu.class.getName()).log(Level.SEVERE, null, ex);
        }
        try {
               
                tipo.setNombre(cmbTipoEmergencia.getSelectedItem().toString());
                ArrayList entidades= tipo.listarEntidades();
                String res="";
                for (int i=0;i<entidades.size();i++)res=res+entidades.get(i)+"\n";
                txaEntidades.setText(res);
            } catch (BuscarDatosEmergenciaException ex) {
                JOptionPane.showMessageDialog(this, ex.getMessage());
            }
    }//GEN-LAST:event_jButton2ActionPerformed

    private void jButton1ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jButton1ActionPerformed
        Tipo tipo=new Tipo();
         Entidad entidad=new Entidad();
        try {
            
            tipo.setNombre(cmbTipoEmergencia.getSelectedItem().toString());
            tipo.buscar();
            
           
            entidad.setNombre(cmbEntidades.getSelectedItem().toString());
            entidad.buscar();
            tipo.quitarEntidad(entidad);
            
        } catch (BuscarDatosEntidadException ex) {
            JOptionPane.showMessageDialog(this, ex.getMessage());
        } catch (BuscarDatosEmergenciaException ex) {
            JOptionPane.showMessageDialog(this, ex.getMessage());
        } catch (GuardarDatosTipoException ex) {
            Logger.getLogger(Menu.class.getName()).log(Level.SEVERE, null, ex);
        }
        try {
                
                tipo.setNombre(cmbTipoEmergencia.getSelectedItem().toString());
                ArrayList entidades= tipo.listarEntidades();
                String res="";
                for (int i=0;i<entidades.size();i++)res=res+entidades.get(i)+"\n";
                txaEntidades.setText(res);
            } catch (BuscarDatosEmergenciaException ex) {
                JOptionPane.showMessageDialog(this, ex.getMessage());
            }
    }//GEN-LAST:event_jButton1ActionPerformed

    /**
     * @param args the command line arguments
     */
    public static void main(String args[]) {
        /* Set the Nimbus look and feel */
        //<editor-fold defaultstate="collapsed" desc=" Look and feel setting code (optional) ">
        /* If Nimbus (introduced in Java SE 6) is not available, stay with the default look and feel.
         * For details see http://download.oracle.com/javase/tutorial/uiswing/lookandfeel/plaf.html 
         */
        try {
            for (javax.swing.UIManager.LookAndFeelInfo info : javax.swing.UIManager.getInstalledLookAndFeels()) {
                if ("Nimbus".equals(info.getName())) {
                    javax.swing.UIManager.setLookAndFeel(info.getClassName());
                    break;
                }
            }
        } catch (ClassNotFoundException ex) {
            java.util.logging.Logger.getLogger(Menu.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
        } catch (InstantiationException ex) {
            java.util.logging.Logger.getLogger(Menu.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
        } catch (IllegalAccessException ex) {
            java.util.logging.Logger.getLogger(Menu.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
        } catch (javax.swing.UnsupportedLookAndFeelException ex) {
            java.util.logging.Logger.getLogger(Menu.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
        }
        //</editor-fold>

        /* Create and display the form */
        java.awt.EventQueue.invokeLater(new Runnable() {
            public void run() {
                new Menu().setVisible(true);
            }
        });
    }
    // Variables declaration - do not modify//GEN-BEGIN:variables
    private javax.swing.JTabbedPane EstadosEmergencia;
    private javax.swing.JButton btnConectar;
    private javax.swing.JButton btnGrabarEntidad;
    private javax.swing.JButton btnGrabarusuario;
    private javax.swing.JButton btnNuevo;
    private javax.swing.JButton cmbBuscar;
    private javax.swing.JComboBox cmbCoordinador;
    private javax.swing.JComboBox cmbEntidades;
    private javax.swing.JComboBox cmbEstadoEmergencia;
    private javax.swing.JButton cmbGrabarEmergencia;
    private javax.swing.JButton cmbGrabarEmergencia1;
    private javax.swing.JComboBox cmbOperador;
    private javax.swing.JComboBox cmbTipoEmergencia;
    private javax.swing.JComboBox cmbTipoUsuario;
    private javax.swing.JButton jButton1;
    private javax.swing.JButton jButton2;
    private javax.swing.JEditorPane jEditorPane1;
    private javax.swing.JLabel jLabel1;
    private javax.swing.JLabel jLabel10;
    private javax.swing.JLabel jLabel11;
    private javax.swing.JLabel jLabel12;
    private javax.swing.JLabel jLabel13;
    private javax.swing.JLabel jLabel14;
    private javax.swing.JLabel jLabel15;
    private javax.swing.JLabel jLabel16;
    private javax.swing.JLabel jLabel17;
    private javax.swing.JLabel jLabel2;
    private javax.swing.JLabel jLabel22;
    private javax.swing.JLabel jLabel23;
    private javax.swing.JLabel jLabel24;
    private javax.swing.JLabel jLabel25;
    private javax.swing.JLabel jLabel26;
    private javax.swing.JLabel jLabel27;
    private javax.swing.JLabel jLabel28;
    private javax.swing.JLabel jLabel29;
    private javax.swing.JLabel jLabel3;
    private javax.swing.JLabel jLabel30;
    private javax.swing.JLabel jLabel31;
    private javax.swing.JLabel jLabel32;
    private javax.swing.JLabel jLabel33;
    private javax.swing.JLabel jLabel34;
    private javax.swing.JLabel jLabel35;
    private javax.swing.JLabel jLabel36;
    private javax.swing.JLabel jLabel37;
    private javax.swing.JLabel jLabel38;
    private javax.swing.JLabel jLabel39;
    private javax.swing.JLabel jLabel4;
    private javax.swing.JLabel jLabel5;
    private javax.swing.JLabel jLabel6;
    private javax.swing.JLabel jLabel7;
    private javax.swing.JLabel jLabel8;
    private javax.swing.JLabel jLabel9;
    private javax.swing.JPanel jPanel1;
    private javax.swing.JPanel jPanel10;
    private javax.swing.JPanel jPanel12;
    private javax.swing.JPanel jPanel2;
    private javax.swing.JPanel jPanel3;
    private javax.swing.JPanel jPanel4;
    private javax.swing.JPanel jPanel5;
    private javax.swing.JPanel jPanel6;
    private javax.swing.JPanel jPanel9;
    private javax.swing.JPasswordField jPasswordField1;
    private javax.swing.JScrollPane jScrollPane1;
    private javax.swing.JScrollPane jScrollPane2;
    private javax.swing.JScrollPane jScrollPane3;
    private javax.swing.JScrollPane jScrollPane4;
    private javax.swing.JScrollPane jScrollPane5;
    private javax.swing.JScrollPane jScrollPane6;
    private javax.swing.JScrollPane jScrollPane7;
    private javax.swing.JScrollPane jScrollPane8;
    private javax.swing.JScrollPane jScrollPane9;
    private javax.swing.JSeparator jSeparator1;
    private javax.swing.JSeparator jSeparator2;
    private javax.swing.JTabbedPane jTabbedPane3;
    private javax.swing.JTabbedPane jTabbedPane4;
    private javax.swing.JLabel lblMensajeBuscarEmergencia;
    private javax.swing.JLabel lblResultado;
    private javax.swing.JLabel lblmensaje;
    private javax.swing.JTable tblEmergencias;
    private javax.swing.JTable tblEntidad;
    private javax.swing.JTable tblusuarios;
    private javax.swing.JTabbedPane tbpPrincipal;
    private javax.swing.JTextArea txaCaso;
    private javax.swing.JTextArea txaEntidades;
    private javax.swing.JTextArea txaEntidadesReporte;
    private javax.swing.JTextArea txaTipos2;
    private javax.swing.JTextArea txaTiposReporte;
    private javax.swing.JTextField txtCIResponsable;
    private javax.swing.JTextField txtCedulaEmergencia;
    private javax.swing.JTextField txtCedulaReporte;
    private javax.swing.JTextField txtCedulausuario;
    private javax.swing.JTextField txtContrasena;
    private javax.swing.JTextField txtContrasenausuario;
    private javax.swing.JTextField txtCorreoResponsable;
    private javax.swing.JTextField txtDescripcion;
    private javax.swing.JTextField txtId;
    private javax.swing.JTextField txtId1;
    private javax.swing.JTextField txtIdReporte;
    private javax.swing.JTextField txtNombre;
    private javax.swing.JTextField txtNombreEmergencia;
    private javax.swing.JTextField txtNombreEmergenciaReporte;
    private javax.swing.JTextField txtNombreResponsable;
    private javax.swing.JTextField txtNombreUsuario;
    private javax.swing.JTextField txtOperadorReporte;
    private javax.swing.JTextField txtTelefono;
    private javax.swing.JTextField txtTelefonoReporte;
    private javax.swing.JTextField txtTelefonoResponsable;
    private javax.swing.JTextField txtUbicacion;
    private javax.swing.JTextField txtUbicacionReporte;
    private javax.swing.JTextField txtcedula;
    private javax.swing.JTextField txtdescripcionReporte;
    private javax.swing.JTextField txtestadoReporte;
    private javax.swing.JTextField txtfecha;
    private javax.swing.JTextField txtfechareporte;
    // End of variables declaration//GEN-END:variables

    private void Actualizar() {
        try {
            ArrayList lista=new Emergencia().listar();
                DefaultTableModel temp = (DefaultTableModel) tblEmergencias.getModel();
                for (int i = tblEmergencias.getRowCount() - 1; i >= 0; i--) {
                    temp.removeRow(i);
                }
                for (int i = 0; i < lista.size(); i++) {
                    Emergencia otraEm = new Emergencia();
                    otraEm = (Emergencia) lista.get(i);
                    Object nuevo[] = {otraEm.getIdEmergencia(),otraEm.getDescripcion(),otraEm.getUbicacion(),otraEm.getTelefono()};
                    temp.addRow(nuevo);
                }
                tblEmergencias.setModel(temp);
        } catch (BuscarDatosEmergenciaException ex) {
            JOptionPane.showMessageDialog(this, ex.getMessage());
        }
    }
    private void ActualizarEntidades(){
        try {
            ArrayList lista=unaEntidad.listar();
            DefaultTableModel temp = (DefaultTableModel) tblEntidad.getModel();
            for (int i = tblEntidad.getRowCount() - 1; i >= 0; i--) {
                temp.removeRow(i);
            }
            for (int i = 0; i < lista.size(); i++) {
                Entidad otraEnt = new Entidad();
                otraEnt = (Entidad) lista.get(i);
                Object nuevo[] = {otraEnt.getIdEntidad(), otraEnt.getNombre()};
                temp.addRow(nuevo);
            }
            tblEntidad.setModel(temp);
        } catch (BuscarDatosEntidadException ex) {
            JOptionPane.showMessageDialog(this, ex.getMessage());
        }

    }    
    
    public void deshabilitar()
    {
        tbpPrincipal.setEnabledAt(1, false);
        tbpPrincipal.setEnabledAt(2, false);
        tbpPrincipal.setEnabledAt(3, false);
    }
    private void Actualizarusuarios(){
        try{
            ArrayList lista=new Persona().listarPersona();
                DefaultTableModel temp = (DefaultTableModel) tblusuarios.getModel();
                for (int i = tblusuarios.getRowCount() - 1; i >= 0; i--) {
                    temp.removeRow(i);
                }
                for (int i = 0; i < lista.size(); i++) {
                    Persona otraEm = new Persona();
                    otraEm = (Persona) lista.get(i);
                    Object nuevo[] = {otraEm.getCedula(),otraEm.getNombre()};
                    temp.addRow(nuevo);
                }
                tblusuarios.setModel(temp);            
        }
        catch (BuscarDatosPersonaException ex){
            JOptionPane.showMessageDialog(this, ex.getMessage());
        }

    }    
}
